$(function () {
    var idData = new Array();
    if(showId !='0'){
        var em = $("#help-text-"+showId);
        var helpId = em.data('id');
        showText(helpId);
        var panel = $("#help-text-"+showId).parent().parent().parent().parent();
        var div = $(panel).find('.panel-heading');
        if(div.attr('id')!='heading0'){
            var am = $(panel).find('.panel-heading a');
            am.click();
        }
    }else{
        var list = $("#accordion .panel-body a");
        var em = list[0];
        var showEm = $(em);
        showText(showEm.data('id'));
    }
    $("body").on('click',".panel-body a",function () {
        var _this = $(this);
        showText(_this.data('id'));
    });

    /**
     * 显示内容
     * @param helpId
     */
    function showText(helpId) {
        var contextEm = $("#help-text-"+helpId);
        $("#show-context-box").html('');
        if(idData.indexOf(helpId)==-1){
            $.ajax({
                url: baseloaction + '/web/help/showContext',
                type:'post',
                dataType:'json',
                data:{
                    'helpId':helpId,
                },
                success:function(result){
                    if(result.success==true){
                        idData.push(helpId);
                        var obj = result.entity;
                        $("#show-context-box").html(obj.context);
                        contextEm.val(obj.context);
                    }
                }
            });
        }else{
            var context = contextEm.val();
            $("#show-context-box").html(context);
        }
    }
});